﻿<%@ Page Language="c#" ContentType="text/html" ResponseEncoding="utf-8" Async="true" MasterPageFile="~/administration/home_private.master" %>
<%@ MasterType VirtualPath="~/administration/home_private.master" %>





<script language="c#" runat="server">
	private System.Resources.ResourceManager rm;
	private System.Data.DataSet dsMenu;
	private System.Data.DataSet dsAdminMenu;
	void Page_Load(object o, EventArgs e) {
			if(ACM.cmsarea08.Users.CurrentUser.Role.Score>400)
				Response.Redirect("/loginadm.aspx");
			if(Application["RM_ADM"]!=null)
    			rm = (System.Resources.ResourceManager) Application["RM_ADM"];
			if(this.Master is ACM.cmsarea08.Administration.Core.ListerPrivate) {
				((ACM.cmsarea08.Administration.Core.ListerPrivate)this.Master).adm_button.Visible=false;	
			}
			dsMenu = ACM.cmsarea08.Administration.Core.Layout.Funzioni.LayoutHandler.getAdminMenu(ACM.cmsarea08.Users.CurrentUser.PrefLanguage,
					                                                        ACM.cmsarea08.Users.CurrentUser.Ruoli);
			if( dsAdminMenu == null) 
						dsAdminMenu = ACM.cmsarea08.Administration.Core.Layout.Funzioni.LayoutHandler.GetCustomAdminMenu(ACM.cmsarea08.Users.CurrentUser.Ruoli,ACM.cmsarea08.Users.CurrentUser.PrefLanguage);																			
						
						
			if(dsAdminMenu!=null)
					dsMenu = ACM.cmsarea08.Administration.Core.Layout.Funzioni.LayoutHandler.ApplyCustomMenu
							(dsAdminMenu,ACM.cmsarea08.Users.CurrentUser.PrefLanguage);
			
				
			if(dsMenu!=null && dsMenu.Tables.Count!=0 && dsMenu.Tables[0].Rows.Count!=0)
				CostruisciListe();
	}
	private void CostruisciListe(){
		string padre = "";
		treePF.Controls.Clear();
		string miomenu = "";
		bool openRow=false;
		foreach(System.Data.DataRow dr in dsMenu.Tables[0].Select("link<>'#'","figliodi asc,ordine asc")){

			if(dr["link"].ToString().ToLower() == "/administration/default.aspx") continue;
			if(padre=="" || dr["figliodi"].ToString()!=padre) {
				if(padre == "") {
					openRow=true;
					padre=dr["figliodi"].ToString();
					System.Data.DataRow[] drpadri = dsMenu.Tables[0].Select("id='" + dr["figliodi"].ToString()+"'","figliodi");
					if(drpadri.Length>0)  {
						miomenu += "<h3 class=\"menuDad atStart\">"+drpadri[0]["nome"].ToString()+"</h3><div class=\"atStart\"><ul class=\"blocchi\">";
					} else
						openRow=false;						
				} else {
					openRow=true;
					padre=dr["figliodi"].ToString();
					System.Data.DataRow[] drpadri = dsMenu.Tables[0].Select("id='" + dr["figliodi"].ToString()+"'","figliodi");
					if(drpadri.Length>0) {
						if(miomenu.EndsWith("</li>"))
							miomenu += "</ul></div>";
						miomenu += "<h3 class=\"menuDad atStart\">"+drpadri[0]["nome"].ToString()+"</h3><div class=\"atStart\"><ul class=\"blocchi\">";
					} else {
						if(miomenu.EndsWith("</li>"))
							miomenu += "</ul></div>";
						openRow=false;
					}
				}
			}
			
			if(dr["link"].ToString()!="#") {
				if(openRow)
					miomenu += ("<li class=\"items\"><a href=\"" + dr["link"].ToString() +
					"?idc=" +dr["id_component"].ToString() +"&amp;idi=" + dr["id_instance"].ToString() + "\" >" + dr["nome"].ToString() + "</a></li>") ;
				else
					miomenu += ("<div class=\"singleitems\"><a href=\"" + dr["link"].ToString() + 
					"?idc=" +dr["id_component"].ToString() +"&amp;idi=" + dr["id_instance"].ToString() + "\" >" + dr["nome"].ToString() + "</a></div>") ;
			}
		/*	
			if(dr["link"].ToString()!="#") {
				if(openRow)
					miomenu += ("<li class=\"items\"><a href=\"" + dr["link"].ToString() +
					"?idc=" +dr["id_component"].ToString() +"&amp;idi=" + dr["id_instance"].ToString() + "\" >" + dr["nome"].ToString() + "</a></li>") ;
				else
					miomenu += ("<div class=\"singleitems\"><a href=\"" + dr["link"].ToString() + 
					"?idc=" +dr["id_component"].ToString() +"&amp;idi=" + dr["id_instance"].ToString() + "\" >" + dr["nome"].ToString() + "</a></div>") ;
			}
		*/
			
		}
		if(miomenu.EndsWith("</li>"))
			miomenu+="</ul></div>";
		treePF.Controls.Add(new LiteralControl(miomenu));
	}


</script>
<asp:Content ID="PageBody" Runat="server" ContentPlaceHolderID="MasterBody">
<h1><%= rm.GetString("ciao")+" "+ACM.cmsarea08.Users.CurrentUser.UserName %></h1>
<div style="clear:both; margin-bottom:5px; overflow:auto;">
	<div id="actionDIV">
    <h2><%= rm.GetString("adm_menu") %></h2>
    <div id="treePF" class="lista" runat="server">
    	<!--<li></%= rm.GetString("hot_links") %>
        	<ul>
            	<li>Gestione utenti</li>
            	<li><a href="core/configuration.aspx?idf=0&amp;new=0">Gestione Portale</a></li>
                <li><a href="core/gesbloccov.aspx">Impatto Visivo</a></li>
                <li><a href="core/gesmedia.aspx">Media Manager</a></li>
                <li><a href="core/gescomponent.aspx">Gestione Componenti</a></li>
        	</ul>
        </li>
        <li>Guida all'uso</li>
    	<li>About</li> -->
    </div>
	</div>

    
    <div id="infoDIV">
    	<div id="welcomeDIV">
            <h2>ATTENZIONE</h2>
            <p>Siamo spiacenti, ma non hai i permessi necessari per visualizzare questa pagina<br/></p>
         </div>
         <div id="tabDIV" <%= ACM.cmsarea08.Users.CurrentUser.Role.Score>99?"style=\"display:none;\"":"" %>>
         	<div class="tabber">
            	<!-- 
                	per quanto riguarda i tabs introdurre chiamate ajax al cambio della slide..
                    come embeds di medins, in modo da evitare sovraccarichi nella pagina e da poter
                    passare per argomento l'id utente in modo da caricare solo le info legate alla tipologia di utente
                    Le tab verranno generate rispetto al tipo di utente, l'esempio mostra il massimo che si può vedere "SYSADM" 
                -->
                
                
         		<div class="tabbertab">
                    <h5>Articoli</h5>
                    <div id="artContEna"></div>                    
                    <div id="artContMod"></div>                    
                    <p style="display:block; background:#FFFFCC; border:1px solid #e2e3e0; margin:5px; padding:5px;">
                	suggerimenti articoli                  
                    </p>
               </div>
               
         		<div class="tabbertab">
                    <h5>Categorie</h5>
                    <div id="catContEna"></div>                    
                    <div id="catContMod"></div> 
                    <p style="display:block; background:#FFFFCC; border:1px solid #e2e3e0; margin:5px; padding:5px;">
                	suggerimenti categorie                     
                    </p>                    
               </div>

         		<div class="tabbertab">
                    <h5>Sezioni</h5>
                    <div id="sezContEna"></div>                    
                    <div id="sezContMod"></div> 
                    <p style="display:block; background:#FFFFCC; border:1px solid #e2e3e0; margin:5px; padding:5px;">
                	suggerimenti sezioni                  
                    </p>                    
               </div>

         		<div class="tabbertab">
                    <h5>Utenti</h5>
                    <div id="usersContNew"></div>                    
                    <div id="usersContLast"></div> 
                    <div id="usersContOnline"></div> 
                    <p style="display:block; background:#FFFFCC; border:1px solid #e2e3e0; margin:5px; padding:5px;">
                	suggerimenti utenti                   
                    </p>                    
               </div>
            
            </div>
         </div> 
          
          
    </div>
    
    


    <br style="clear:both; margin:3px 0px; padding:0px; display:block;" />
</div>
<br class="clearbr" style="margin-bottom:10px;" />
<script language="javascript">
window.addEvent('domready', function() {
	
	var myAccordion = new Accordion($('accordion'), 'h3.atStart', 'div.atStart', {
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#f26b22');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#222');
		}
	}, $('<% Response.Write(treePF.ClientID); %>'));


});
</script>

</asp:content>
